commonlibsse_ng\re\t/
TESObjectCELL.rs

1use crate::re::BGSEncounterZone::BGSEncounterZone;
2use crate::re::BSAtomic::BSSpinLock;
3use crate::re::BSBitField::BSBitField;
4use crate::re::BSPointerHandle::ObjectRefHandle;
5use crate::re::BSTArray::BSTArray;
6use crate::re::BSTList::BSSimpleList;
7use crate::re::BSTSmartPointer::BSTSmartPointer;
8use crate::re::ExtraDataList::ExtraDataList;
9use crate::re::FormTypes::FormType;
10use crate::re::InteriorData::INTERIOR_DATA;
11use crate::re::NiSmartPointer::NiPointer;
12use crate::re::TESForm::TESForm;
13use crate::re::TESFullName::TESFullName;
14use crate::re::TESObjectREFR::TESObjectREFR;
15use crate::re::TESWorldSpace::TESWorldSpace;
16use crate::re::offsets_rtti::RTTI_TESObjectCELL;
17use crate::re::offsets_vtable::VTABLE_TESObjectCELL;
18use crate::re::{
19    BGSLightingTemplate, BGSWaterUpdateI, BSMultiBoundNode, BSPortalGraph, BSTMap, BSTSet, NavMesh,
20    NiNode, TESObjectLAND,
21};
22use crate::rel::id::VariantID;
23use core::sync::atomic::AtomicI32;
24
25#[repr(C)]
26#[derive(Debug)]
27pub struct BGSTerrainVisibilityData {
28    pub visData: *mut BSBitField, // 0x0
29}
30const _: () = assert!(core::mem::size_of::<BGSTerrainVisibilityData>() == 0x8);
31
32// EXTERIOR_DATA (XCLC)
33#[repr(C)]
34#[derive(Debug)]
35pub struct EXTERIOR_DATA {
36    pub cellX: i32,                                // 0x00
37    pub cellY: i32,                                // 0x04
38    pub maxHeightData: *mut i8,                    // 0x08
39    pub lodVisData: *mut BGSTerrainVisibilityData, // 0x10
40    pub worldX: f32,                               // 0x18
41    pub worldY: f32,                               // 0x1C
42    pub landHideFlags: u8,                         // 0x20 - Using raw u8 for enum
43    pub pad21: u8,                                 // 0x21
44    pub pad22: u16,                                // 0x22
45    pub pad24: u32,                                // 0x24
46}
47const _: () = assert!(std::mem::size_of::<EXTERIOR_DATA>() == 0x28);
48
49#[commonlibsse_ng_derive_internal::to_bitflags]
50#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
51pub enum LandHideFlag {
52    None = 0,
53    Quad1 = 1 << 0,
54    Quad2 = 1 << 1,
55    Quad3 = 1 << 2,
56    Quad4 = 1 << 3,
57}
58
59// NavMeshArray
60#[repr(C)]
61pub struct NavMeshArray {
62    pub navMeshes: BSTArray<BSTSmartPointer<NavMesh>>, // 0x00
63}
64const _: () = assert!(std::mem::size_of::<NavMeshArray>() == 0x18);
65
66// LOADED_CELL_DATA
67#[repr(C)]
68pub struct LOADED_CELL_DATA {
69    pub portalGraph: NiPointer<BSPortalGraph>,       // 0x000
70    pub cell3D: NiPointer<NiNode>,                   // 0x008
71    pub lightMarkerNode: NiPointer<NiNode>,          // 0x010
72    pub soundMarkerNode: NiPointer<NiNode>,          // 0x018
73    pub multiBoundNode: NiPointer<NiNode>,           // 0x020
74    pub unk028: u64,                                 // 0x028
75    pub unk030: u64,                                 // 0x030
76    pub unk038: u64,                                 // 0x038
77    pub unk040: BSTArray<ObjectRefHandle>,           // 0x040
78    pub flickeringLights: BSTArray<ObjectRefHandle>, // 0x058
79    pub emittanceSourceRefMap: BSTMap<*mut TESForm, ObjectRefHandle>, // 0x070
80    pub emittanceLightRefMap: BSTMap<ObjectRefHandle, *mut NiNode>, // 0x090
81    pub multiboundRefMap: BSTMap<ObjectRefHandle, NiPointer<BSMultiBoundNode>>, // 0x0B0
82    pub refMultiboundMap: BSTMap<*mut BSMultiBoundNode, ObjectRefHandle>, // 0x0D0
83    pub activatingRefs: BSSimpleList<ObjectRefHandle>, // 0x0F0
84    pub unk100: BSSimpleList<ObjectRefHandle>,       // 0x100
85    pub unk110: u64,                                 // 0x110
86    pub unk118: BSTArray<*mut ()>,                   // 0x118
87    pub decalRefs: BSTArray<ObjectRefHandle>,        // 0x130
88    pub skyActors: BSTArray<ObjectRefHandle>,        // 0x148
89    pub encounterZone: *mut BGSEncounterZone,        // 0x160
90    pub decalsQueued: bool,                          // 0x168
91    pub criticalQueuedRefCount: AtomicI32,           // 0x16C
92    pub queuedRefCount: AtomicI32,                   // 0x170
93    pub queuedDistantRefCount: AtomicI32,            // 0x174
94    pub unk178: i32,                                 // 0x178
95    pub refsFullyLoaded: bool,                       // 0x17C
96}
97const _: () = assert!(std::mem::size_of::<LOADED_CELL_DATA>() == 0x180);
98
99#[repr(C)]
100#[derive(Debug)]
101pub struct TESObjectCELL {
102    // Base classes
103    pub tes_form: TESForm,          // 0x000
104    pub tes_full_name: TESFullName, // 0x020
105
106    // Members
107    pub grassCreateLock: BSSpinLock, // 0x030
108    pub grassTaskLock: BSSpinLock,   // 0x038
109    pub cellFlags: u16,              // 0x040 - Using raw u16 for enum
110    pub cellGameFlags: u16,          // 0x042
111    pub cellState: u8,               // 0x044 - Using raw u8 for enum
112    pub autoWaterLoaded: bool,       // 0x045
113    pub cellDetached: bool,          // 0x046
114    pub pad047: u8,                  // 0x047
115    pub extraList: ExtraDataList,    // 0x048
116
117    // Runtime Data
118    pub cellData: CellData,                           // 0x060
119    pub cellLand: *mut TESObjectLAND,                 // 0x068
120    pub waterHeight: f32,                             // 0x070
121    pub navMeshes: *mut NavMeshArray,                 // 0x078
122    pub references: BSTSet<NiPointer<TESObjectREFR>>, // 0x080
123    pub unk0B0: *mut TESForm,                         // 0x0B0
124    pub objectList: BSTArray<*mut TESObjectREFR>,     // 0x0B8
125    pub unk0D0: BSTArray<*mut ()>,                    // 0x0D0
126    pub waterObjects: BSTArray<*mut BGSWaterUpdateI>, // 0x0E8
127    pub unk100: BSTArray<*mut ()>,                    // 0x100
128    pub spinLock: BSSpinLock,                         // 0x118
129    pub worldSpace: *mut TESWorldSpace,               // 0x120
130    pub loadedData: *mut LOADED_CELL_DATA,            // 0x128
131    pub lightingTemplate: *mut BGSLightingTemplate,   // 0x130
132    pub unk138: u64,                                  // 0x138
133}
134
135#[repr(C)]
136pub union CellData {
137    pub exterior: *mut EXTERIOR_DATA,
138    pub interior: *mut INTERIOR_DATA,
139}
140const _: () = assert!(std::mem::size_of::<CellData>() == 0x8);
141impl core::fmt::Debug for CellData {
142    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
143        unsafe {
144            f.debug_struct("CellData")
145                .field("exterior", &self.exterior)
146                .field("interior", &self.interior)
147                .finish()
148        }
149    }
150}
151
152impl TESObjectCELL {
153    pub const RTTI: VariantID = RTTI_TESObjectCELL;
154    pub const VTABLE: [VariantID; 2] = VTABLE_TESObjectCELL;
155    pub const FORM_TYPE: FormType = FormType::Cell;
156}
157
158pub enum Flag {
159    None = 0,
160    IsInteriorCell = 1 << 0,
161    HasWater = 1 << 1,
162    CanTravelFromHere = 1 << 2,
163    NoLODWater = 1 << 3,
164    HasTempData = 1 << 4,
165    PublicArea = 1 << 5,
166    HandChanged = 1 << 6,
167    ShowSky = 1 << 7,
168    UseSkyLighting = 1 << 8,
169    WarnToLeave = 1 << 9,
170}
171
172pub enum CellState {
173    Attached = 7,
174}